package com.wc.算法基础课.A第一讲基础算法.双指针.日志统计;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/5 14:37
 * @description https://www.acwing.com/problem/content/1240/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static boolean[] st = new boolean[N];
    static int[] cnt = new int[N];
    static Pair[] logs = new Pair[N];
    static int n, d, k;

    public static void main(String[] args) {
        n = sc.nextInt();
        d = sc.nextInt();
        k = sc.nextInt();
        for (int i = 0; i < n; i++) {
            logs[i] = new Pair(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(logs, 0, n);
        // 双指针遍历时间，超出时间就做坏事
        for (int i = 0, j = 0; i < n; i++) {
            // id来了
            int id = logs[i].y;
            // 给他加上
            cnt[id]++;
            while (logs[i].x - logs[j].x >= d) {
                // 超出时间就枪毙一个
                cnt[logs[j].y]--;
                j++;
            }
            if (cnt[id] >= k) st[id] = true;
        }
        for (int i = 0; i < N; i++) {
            if (st[i]) out.println(i);
        }
        out.flush();
    }

    static class Pair implements Comparable<Pair> {
        int x, y;

        Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(Pair o) {
            if (x == o.x) {
                return y - o.y;
            }
            return x - o.x;
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
